package com.gengzi.user.pojo;


import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Pattern;
import java.util.Date;

/**
 * @author 董诗攀
 */
@Table(name = "tb_user")
@Data
@ApiModel(value="用户表")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @ApiModelProperty(value="用户id" ,required=true)
    private Long id;
    @ApiModelProperty(value="用户名" ,required=true)
    @Length(min = 4, max = 30, message = "用户名只能在4~30位之间")
    private String username;

    @JsonIgnore
    @ApiModelProperty(value="密码",required=true)
    @Length(min = 4, max = 30, message = "密码只能在4~30位之间")
    private String password;

    @ApiModelProperty(value="电话",required=true)
    @Pattern(regexp = "^1[35678]\\d{9}$", message = "手机号格式不正确")
    private String phone;

    @ApiModelProperty(value="创建时间")
    private Date created;

    @JsonIgnore
    @ApiModelProperty(value="密码的盐值")
    private String salt;
}